<template>
	<el-dialog
		title="标识维护"
		:visible.sync="addFlagShow"
		width="70%"
		:before-close="cancel"
		:close-on-click-modal="false"
		:close-on-press-escape="false"
	>
		<el-button style="margin-bottom:16px;" type="primary" size="mini" @click="addComFunc('新增')" icon="el-icon-circle-plus-outline"
			>新 增</el-button
		>
		<el-table
			:data="SignList"
			row-key="reminderTypeId"
			border
			style="width: 100%"
			:tree-props="{ children: 'nextRemindTypes', hasChildren: 'hasChildren' }"
			:header-cell-style="{ background: '#FAFAFA' }"
			v-loading="getDataLoading"
			element-loading-text="正在加载数据，请耐心等待......"
			element-loading-spinner="el-icon-loading"
			element-loading-background="rgba(0, 0, 0, 0.8)"
		>
			<el-table-column prop="reminderName" label="标识名称" align="left"> </el-table-column>
			<el-table-column prop="reminderKey" label="标识KEY" align="left" width="300"> </el-table-column>
			<el-table-column prop="address" label="操作" align="left" width="200">
				<template slot-scope="scope">
					<el-button type="primary" icon="el-icon-edit" @click="addComFunc('编辑', scope.row)" size="mini">编辑</el-button>
					<el-button type="danger" icon="el-icon-delete" @click="btnClick('删除', scope.row)" size="mini">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<span slot="footer" class="dialog-footer">
			<el-button @click="cancel" size="small">关 闭</el-button>
		</span>
		<addCom
			:title="title"
			:addFlagShow="addComShow"
			:SignList="SignList"
			@addFlagFunc="addComFunc"
			@queryFundManagerList="getData"
			ref="addCom"
		/>
	</el-dialog>
</template>
<script>
	import { ReminderSign, ReminderDeleteFlag } from '@/api/Reminder/index.js'
	import addCom from './addCom.vue'
	export default {
		components: {
			addCom
		},

		props: {
			addFlagShow: {
				type: Boolean,
				default: false
			},
			addFlagFunc: {
				type: Function,
				default: Function
			},
			queryFundManagerList: {
				type: Function,
				default: Function
			}
		},

		data() {
			return {
				SignList: [],
				addComShow: false,
				getDataLoading: false,
				title: ''
			}
		},

		mounted() {
			this.getData()
		},

		methods: {
			addComFunc(title, item) {
				this.title = title
				this.addComShow = !this.addComShow
				if (item) {
					this.$nextTick(() => {
						this.$refs.addCom.edit(item)
					})
				}
			},

			btnClick(type, item) {
				if (type === '编辑') {
					this.addComFunc(item)
				} else {
					this.operatorComfirm(() => {
						ReminderDeleteFlag(item).then(res => {
							if (res.msgCode === 'Y') {
								this.$message({ showClose: true, message: res.msg, customClass: 'el-messageClass', type: 'success' })
								this.getData()
							}
						})
					}, `删除该提醒标识`)
				}
			},

			cancel() {
				this.$emit('addFlagFunc')
				this.$emit('queryFundManagerList')
			},

			getData() {
				this.getDataLoading = true
				ReminderSign()
					.then(res => {
						if (res.msgCode === 'Y') {
							this.SignList = res.data.body
						}
					})
					.finally(() => {
						this.$nextTick(() => {
							this.getDataLoading = false
						})
					})
			}
		}
	}
</script>
<style lang="scss" scoped >
	::v-deep th {
		padding: 8px 0;
	}

	::v-deep td {
		padding: 6px 0 !important;
	}
</style>
